<%@ page import="pojo.Paper" %>
<%@ page import="java.util.List" %>
<%@ page import="java.text.SimpleDateFormat" %>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<html>
<head>
    <title>试卷管理</title>
    <jsp:include page="teacher_menu.jsp"></jsp:include>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <!-- 引入各种CSS样式表 -->
    <link rel="stylesheet" href="css/bootstrap.css">
    <link rel="stylesheet" href="css/index.css">
    <%--    图标--%>
    <link rel="stylesheet" href="icon/iconfont.css">
    <link rel="stylesheet" href="http://at.alicdn.com/t/c/font_4336496_3iu2a7l8bg8.css">
    <!--引入jquery和bootstrap -->
    <script type="text/javascript" src="js/jquery-1.12.3.min.js"></script>
    <script type="text/javascript" src="js/bootstrap.min.js"></script>

    <style>
        .content_input{
            margin-left: 20%;
        }
        .content_input .search_field{ /*输入框样式*/
            margin-top: 20px;
            float: left;
            width: 60%;
            height: 38px;
            border-radius: 5px;
            border: 1px solid #3388FF;
        }
        .content_input .search_btn{ /*按钮样式*/
            width: 80px;
            height: 40px;
            margin-top: 20px;
            margin-left: 20px;
            background-color:dodgerblue;
        }
        .content_input .search_btn:hover{ /*按钮覆盖样式*/
            background-color: #2e6da4;
            color: ivory;
        }
        #content{
            margin-left: 20%;
        }
        #paper-border{
            width: 65%;
            margin-top: 20px;
            display: inline-block;
        }
        #paper-card{
            max-width: 90%;
            margin-left: 20px;
            padding-top: 20px;
        }
        .point-href{
            display: block;
            width: 100%;
            height: 70%;
        }
        .col-md-7{
            height: 150px;
        }
        .href-p{
            color: forestgreen;
        }
        #paper-card a:hover {
            text-decoration: #31708f;
        }
        .row{
            background-color: #d9edf7;
            box-shadow: 2px 2px 2px 0 #b3d4fc ;
        }
        .sentences{
            margin-top: 40px;
            width: 35%;
            height: 450px;
            float: right;
            border-radius: 10px;
        }
        #sentences-border{
            margin-left:20px;
            float: left;
            margin-top: 20px;
        }
        #add_paper{
            width: 120px;
            height: 40px;
            float: left;
            background-color:forestgreen;
        }
        #add_paper:hover{
            background-color: darkgreen;

        }
        .deleteBtn{
            z-index: 9999;
        }
    </style>
</head>
<body>
<%
    String mess=(String)session.getAttribute("message");
    if(mess!=null && !"".equals(mess)){
%>
<script type="text/javascript">
    alert("<%=mess%>");
</script>
<%
        session.setAttribute("message", "");
    } %>

<div style="background-color: #66afe9;display: inline-block;margin-top: 10px;float: left;margin-left: 20%;height: 80px;width: 300px;text-align: center; border-radius:0px;">
    <h1 style="color:white;text-shadow: 2px 2px 2px dodgerblue;line-height: 40px;border-radius:2px;font-size: 25px">试卷管理</h1>
</div>
<div style="margin-left: 35%;margin-top:10px;width: 60%;height:80px;background-color: #66afe9; ">
    <div class="content_input">
        <form action="${pageContext.request.contextPath }/searchPaperByName" method="POST">
            <%--查询--%>
            <input type="text" class="search_field" placeholder="请输入试卷名称" name="p_name" id="p_name">
            <button type="submit" class="btn btn-primary search_btn">查询</button>
        </form>
    </div>
</div>
<br>
<div id="content">
    <button type="button" class="btn btn-primary" id="add_paper" onclick="add_paper()">新增试卷</button>
    <div class="sentences">
        <div class="card" id="sentences-border">
            <h2 style="text-align: center">名人名言</h2>
            <div style="margin-top: 30px">
                <blockquote class="blockquote">
                    <p>师者，所以传道，授业，解惑也。</p>
                    <footer class="blockquote-footer">韩愈 <cite title="Source Title">《师说》</cite></footer>
                </blockquote>
            </div>
            <div>
                <blockquote class="blockquote">
                    <p>春蚕到死丝方尽，蜡炬成灰泪始干。</p>
                    <footer class="blockquote-footer">李商隐 <cite title="Source Title">《无题·相见时难别亦难》</cite></footer>
                </blockquote>
            </div>
            <div>
                <blockquote class="blockquote">
                    <p>春蚕到死丝方尽，蜡炬成灰泪始干。</p>
                    <footer class="blockquote-footer">李商隐 <cite title="Source Title">《无题·相见时难别亦难》</cite></footer>
                </blockquote>
            </div>
        </div>
    </div>
    <div id="paper-border">
        <div class="card" id="paper-card">
            <%
                List<Paper> papers=(List<Paper>)session.getAttribute("get_papers");
                if(papers==null||papers.isEmpty()){
            %>
            您还没有试卷哦~
            <%
            }else{
                for(Paper c:papers){
            %>
            <div class="row">
                <div class="col-md-5">
                    <img src="./image/exam_picture.jpg" class="w-20" width="100%" height="200px">
                </div>
                <div class="col-md-7" style="display: inline-block">
                    <br>
                    <%
                        String stime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(c.getStarttime());
                        String etime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(c.getEndtime());
                        String ifpublish="";
                        if(c.getIfpublish()==1){
                         ifpublish="已发布";
                        }
                        else{
                            ifpublish="未发布";
                        }
                        //String p_name = URLEncoder.encode(c.getP_name(), "UTF-8");
                    %>
                    <a href="loadPaperContent?p_id=<%=c.getP_id()%>" class="point-href"> &copy; <%=c.getP_name()%>>><br><br>
                        <p class="href-p">
                            开始时间：<%=stime%><br>
                            结束时间：<%=etime%><br>
                            状&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;态：<%=ifpublish%>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                        </p></a><br><br>
                </div>
                <div style="z-index: 9999;margin-left: 45%;margin-bottom: 20px">
                    <%
                        //                        Paper paper=new Paper();
//                        paper.setP_id(c.getP_id());
//                        session.setAttribute("paper",paper);
                    %>
                    <button style="font-size: 15px" class="btn btn-info" onclick="add(<%=c.getP_id()%>)">添加试题</button>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                    <button style="font-size: 15px" class="btn btn-danger deleteBtn" onclick="delete_paper(<%=c.getP_id()%>)">删除试卷</button>
                </div>
            </div>
            <br>
            <%
                    }}
            %>
        </div>
    </div>
</div>


<script type="text/javascript">
    function add_paper(){
        window.location.href='add_paper_new.jsp';
        return false;
    }
    function delete_paper(p_id){
        if(window.confirm("您确定要删除该试卷吗？")) {
            window.location.href="${pageContext.request.contextPath}/deletePaper?p_id="+p_id;
        }
        return false;
    }
    function add(p_id){
        if(window.confirm("您确定要在该试卷中添加试题吗？")) {
            window.location.href="${pageContext.request.contextPath}/QuestionList_add?p_id="+p_id;
        }
        return false;
    }
</script>
</body>
</html>